<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/jquery-3.4.1.js"></script>
		<script>
			$(function(){
				$("button").eq(0).click(function(){
					var u = $(":text").val();
					var p = $(":password").val();
					$.post(
						"http://127.0.0.1:8080/test/index.jsp",
						{username:u,password:p},
						function(data){
							$("#res").html(data);
						}
					)
				})
				$("button").eq(1).click(function(){
					var u = $(":text").val();
					var p = $(":password").val();
					$.ajax({
						type:"POST",
						data:{username:u,password:p},
						url:"http://127.0.0.1:8080/test/index.jsp",
						success:function(data){
							$("#res").html(data);
						},
						error:function(data){
							$("#res").html("请求失败！");
						}
					})
				})
			})
		</script>
	</head>
	<body>
		姓名：<input type="text" />
		密码：<input type="password" /><br />
		<button>post方式提交</button>
		<button>Ajax方式提交</button>
		<div>请求返回的结果：</div>
		<span id="res"></span>
	</body>
</html>
